<div class="site_section_header">
	Add/Edit a project
</div>

<?php

if(isset($errors))
{
	echo $errors;
}
else if(isset($message))
{
?><div class="ep_message"><?php echo $message; ?></div><?php
}

$project_title = isset($project_title) ? $project_title : $oProject->project_title;
$project_date_month = isset($project_date_month) ? $project_date_month : $oProject->project_date_month;
$project_date_year = isset($project_date_year) ? $project_date_year : $oProject->project_date_year;
$project_desc = isset($project_desc) ? $project_desc : $oProject->project_desc;
$project_area = isset($project_area) ? $project_area : $oProject->project_area;

?>

<form action="/admin/projects/save_project" method="post" enctype="multipart/form-data" onsubmit="">
<div id="projects_main_wrapper">
	
	<div class="ep_seption">
		<div class="eps_header"><div class="eps_header_name">Project details</div></div>
		<div class="eps_content">
			
			<div class="ep_field_wrapper">
				<div class="ep_field_title">Project title</div>
				<div class="ep_field"><input type="text" name="project_title" id="project_title" value="<?php echo $project_title; ?>" /></div>
				<div class="clear"><!-- --></div>
			</div>
			
			<div class="ep_field_wrapper">
				<div class="ep_field_title">Date</div>
				<div class="ep_field">
					<select name="project_date_month" id="project_date_month">
						<option value=""></option>
					<?php
					for ($i = 1; $i <= 12; $i++)
					{
						$month_text = date("F", mktime(0, 0, 0, $i+1, 0, 0, 0));
						?>
						<option value="<?php echo $i; ?>"<?php echo $project_date_month == $i ? ' selected="selected"' : ''; ?>><?php echo $month_text; ?></option>
						<?php
					}
					?>
					</select> 
					
					<select id="project_date_year" name="project_date_year">
						<option value=""></option>
					<?php
					$start_year = 2008;
					$end_year = date('Y') + 5;
					
					for($i = $start_year; $i < $end_year; $i++)
					{
						?>
						<option value="<?php echo $i; ?>"<?php echo $project_date_year == $i ? ' selected="selected"' : ''; ?>><?php echo $i; ?></option>
						<?php
					}
					?>
					</select>
				</div>
				<div class="clear"><!-- --></div>
			</div>
			
			<div class="ep_field_wrapper">
				<div class="ep_field_title">Area</div>
				<div class="ep_field">
					<?php
					$areas = array(
						1 => 'Car', 
						2 => 'Bus', 
						3 => 'Tube', 
						4 => 'Train', 
						5 => 'Motorcycle', 
						6 => 'Bicycle', 
					);
					?>
					<select name="project_area" id="project_area">
					<?php
					foreach($areas as $area_id => $area)
					{
						?>
						<option value="<?php echo $area_id; ?>"<?php echo $area_id == $project_area ? ' selected="selected"' : ''; ?>><?php echo $area; ?></option>
						<?php
					}
					?>
					</select> 
				</div>
				<div class="clear"><!-- --></div>
			</div>
			
			<div class="ep_field_wrapper">
				<div class="ep_field_title">Description</div>
				<div class="ep_field"><textarea id="project_desc" name="project_desc" style="width:490px; height:55px;"><?php echo $project_desc; ?></textarea></div>
				<div class="clear"><!-- --></div>
			</div>
			
		</div>
	</div>
	
	<div class="ep_seption">
		<div class="eps_header"><div class="eps_header_name">Content</div></div>
		<div class="eps_content">
			<div class="ep_field_wrapper">
				<div class="ep_field_title">JPG<span class="ep_field_required">*</span></div>
				<div class="ep_field"><input type="button" value="Select" onclick="open_media_manager('jpg'); return false;" /> (required to display thumbnail)</div>
				<div class="clear"><!-- --></div>
			</div>
			<div class="ep_field_wrapper">
				<div class="ep_field_title">PDF</div>
				<div class="ep_field"><input type="button" value="Select" onclick="open_media_manager('pdf'); return false;" /></div>
				<div class="clear"><!-- --></div>
			</div>
				
			<div class="ep_field_wrapper">
				<div class="ep_field_title">Current</div>
				<div class="ep_field" id="jpg_wrapper">
				<?php
				if($oProject->jpg_media_id && $oProject->jpg_media_id > 0)
				{
				?>
					<img src="/assets/media/thumbs/<?php echo $oProject->jpg_media_subfolder; ?>/<?php echo $oProject->jpg_media_id; ?>.<?php echo $oProject->jpg_extension_ext; ?>" />
				<?php
				}
				?>
				</div>
				<div class="clear"><!-- --></div>
			</div>
				
		</div>
	</div>
	
	<div style="padding: 2px;">
		<input type="hidden" id="project_jpg" name="project_jpg" value="<?php echo $oProject->jpg_media_id; ?>" />
		<input type="hidden" id="project_pdf" name="project_pdf" value="<?php echo $oProject->pdf_media_id; ?>" />
		<input type="hidden" id="project_id" name="project_id" value="<?php echo $oProject->project_id; ?>" />
		
		<input type="image" id="edit_component_save_button" src="/assets/images/web/admin/buttons/save.png" /> 
		<a href="/admin/projects"><img src="/assets/images/web/admin/buttons/cancel.png" style="border:none;" /></a>
	</div>
	
</div>
</form>